package com.bright.werk_ai.controller;

import com.bright.werk_ai.entity.User;
import com.bright.werk_ai.response.Result;
import com.bright.werk_ai.service.UserService;
import com.bright.werk_ai.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LeiFengLiang
 * @Description: TODO
 * @Classname: UserConntroller
 * @date 2022-05-18 15:28
 */
@RestController
@CrossOrigin
public class UserController {

    @Autowired
    UserService userService;
    @PostMapping( "/login")
    public Result login(@RequestParam(value = "username",required = true) String username,
                        @RequestParam(value = "password",required = true) String password
    )  {
        UserVO loginVo=new UserVO(username,password);
        UserVO login = userService.login(loginVo);
        return Result.ok().data("token",login);
    }
}
